<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class TabsController extends AppController {

    var $name = "Tabs";

    function admin_index() {
        $this->layout = "ajax";
        $this->set("tabs", $this->Tab->find("all", array("fields"=>array("Tab.id","Tab.titulo","Tab.icono"))));
    }

    function admin_add() {
        $this->layout = "ajax";
        if (!empty($this->data)) {
            if ($this->Tab->saveAll($this->data)) {
                $this->Session->setFlash("Pestaña adicionada éxito");
                $this->redirect(array('controller' => 'Tabs', 'action' => 'index'));
            };
        }
    }

    function admin_edit($id) {
        $this->layout = "ajax";
        if (!empty($this->data)) {

            if ($this->Tab->saveAll($this->data)) {
                $this->Session->setFlash("Pestaña ediatada con  éxito");
                $this->redirect(array('controller' => 'Tabs', 'action' => 'index'));
            };
        } else {
            $this->data = $this->Tab->find("first", array("conditions" => array("Tab.id" => $id)));
        }
    }

    function admin_delete($id) {
        if ($this->Tab->delete($id)) {
            $this->Session->setFlash('Pestaña Borrada con exito');
            $this->redirect(array('controller' => 'Tabs', 'action' => 'index'));
        }
    }
    
    function delete($id) {
        if ($this->Tab->delete($id)) {
            $this->Session->setFlash('Pestaña Borrada con exito');
            $this->redirect(array('controller' => 'Tabs', 'action' => 'index'));
        }
    }

    

}

?>
